//! Header for the  class
#ifndef DURATIONCOUNTER_H
#define DURATIONCOUNTER_H

#include "IVisitor.h"
#include "Song.h"

//! A concrete visitor used to calculate the length of the passed Musicmedia.
/*!
	A concrete visitor which calculates the duration of the MusicMedia passed in
	the visit functions and stores the um of the durations in a local Variable.
	The Value 
	\class DurationCounter
	\author Thomas Pfeiffer
	\date 06.12.2012
*/
class DurationCounter : public IVisitor {
public:

	//! The CTor of a DurationCounter
	DurationCounter();

	//! Returns the calculated duration of the MusicMedia
	/*!
	Returns the calculated duration of the MusicMedia. Should be called
	after calling the visit function.
	\return The calculated duration.
	*/
	TDuration getDuration() const;

	void Visit(Song * song);
	void Visit(Album * album);
	void Visit(MusicCollection * collection);
	
private:
	// Stores the duration
	TDuration mDuration;

	// Calls accept on every media in the MusicCollection
	// with a local DurationCounter. Used to calculate the
	// length of albums and collections. (To avoid code doubling)
	void RecursiveVisit(MusicCollection const * mc);
};

#endif